#include <iostream>
#include <string>
#include "BigInt.h"

using namespace std;


void main(){
	int choice, n, loop = 1;
	BigInt data1, data2;
	printf("Welcome to 128bit-Decimal number caculating programme \n");
	printf("To input a negatif value, please add '-' before the number \n");
	printf("Value range: [-0x80000...; 0x777...];  32 heximal digits are allowed \n");
	printf("************************ \n");
	printf(" 1.	Plus \n 2.	Substract \n 3.	Multiplicate \n 4.	Div \n 5.	Mod \n 6.	and \n 7.	or \n 8.	xor \n 9.	not \n 10.	shift left \n 11.	shift right \n");

while(loop == 1){
	printf("Which operator would you like to process ? Enter your choice: \t");
	while(1){
	fflush( stdin);
	scanf("%d",&choice);
		if( choice >= 1 && choice <= 11 )
			break;
	printf("Wrong choice, reenter please :");
	}
	switch(choice){
	case 1: case 2: case 3: case 4: case 5: case 6: case 8:

	printf("_____________________________________________ \n");
	printf(" Enter number A: \n");
	inputBigInt(data1);
	printf(" Enter number B: \n");
	inputBigInt(data2);
	printf("_________________________\n");

		if(choice == 1){
			printf(" A + B = \n");
			outputBigInt(plus(data1, data2));
		}
		if(choice == 2){
			printf(" A - B = \n");
			outputBigInt(minus(data1, data2));
		}
		if(choice == 3){
			printf(" A * B = \n");
			outputBigInt(multi(data1, data2));
		}
		if( choice == 4){
			BigInt quotient;
			if( div(quotient, data1, data2) ){
				printf(" A/B = \n");
				outputBigInt(quotient);
			}else
				printf(" The denominator = 0, hence the division cannot perform \n");
		}
		if( choice == 5){
			BigInt modulo;
			if( mod(modulo, data1, data2) ){
				printf(" A%%B = \n");
				outputBigInt(modulo);
			}else
				printf(" The denominator = 0, hence the division cannot perform \n");
		}
		if(choice == 6){
			printf(" A and B = \n");
			outputBigInt(and(data1, data2));
		}
		if(choice == 7){
			printf(" A or B = \n");
			outputBigInt(or(data1, data2));
		}
		if(choice == 8){
			printf(" A xor B = \n");
			outputBigInt(xor(data1, data2));
		}

	break;
	case 10: case 11:
		printf(" Enter number A: \n");
		inputBigInt(data1);
		printf(" How many bits would you like to shift \n");
		scanf("%d", &n);

		if(choice == 7){
			sfl(data1, n);
			outputBigInt(data1);
		}
		if(choice == 8){
			sfr(data1, n);
			outputBigInt(data1);
		}
	break;
}
	printf("Enter 1 to continue, else to exit \n");
	scanf("%d", &loop);
}
}

